package com.spark.client.exception;

/**
 * 星火客户端异常类
 */
public class SparkClientException extends Exception {
    
    private String errorCode;
    private String errorMessage;

    public SparkClientException(String message) {
        super(message);
        this.errorMessage = message;
    }

    public SparkClientException(String message, Throwable cause) {
        super(message, cause);
        this.errorMessage = message;
    }

    public SparkClientException(String errorCode, String errorMessage) {
        super(errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public SparkClientException(String errorCode, String errorMessage, Throwable cause) {
        super(errorMessage, cause);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    @Override
    public String toString() {
        if (errorCode != null) {
            return "SparkClientException{" +
                    "errorCode='" + errorCode + '\'' +
                    ", errorMessage='" + errorMessage + '\'' +
                    '}';
        } else {
            return "SparkClientException{" +
                    "errorMessage='" + errorMessage + '\'' +
                    '}';
        }
    }
}
